// 自定义指令

import store from '@/store'

// 图片加载不出来就用默认的图片
export const imgerror = {
  inserted: function(el, options) {
    // console.log(el, 'el')
    // console.log(options, 'options')
    el.onerror = () => {
      console.log('图片加载失败后，给一个默认的图片地址')
      // console.log(options.value)
      el.src = options.value
    }
  }
}

// 显示不同用户的权限按钮级别，页面上出现不同的按钮

export const allow = {
  inserted: function(el, options) {
    // console.log(el, 'el')
    // console.log(options, 'options')
    console.log(el, 'el')
    console.log(options, 'options')
    const points = store.state.user.userInfo.roles.points
    console.log(points, 'points')
    if (!points.includes(options.value)) {
      el.style.display = 'none'
    }
  }
}
